<?php
$this->headTitle('Quản lý người dùng', 'append');
?>
<div class="grid">
    <div class="breadcrumbs">
        <a class="item-1" href="/index">Trang chủ</a> › 
        <a class="item-2" href="/admin/user"><?php $title = $this->headTitle(); if(isset($title[0])) echo $title[0]; ?></a>
        <div class="clear-both"></div>
    </div>
        <table border="0" cellspacing="0" cellpadding="0" width="100%">
            <thead>
                <tr>
                    <td class="column">ID</td>
                    <td class="column">Tên tài khoản</td>
                    <td class="column">Quyền</td>
                    <td class="column">Trạng thái</td>
                    <td class="column">
                        <?php if($this->acl->checkResource($this->auth,'admin','user','add')){ ?>
                            <a class="bnt-add" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'add'));?>">
                                Thêm mới
                            </a>
                        <?php }else{ ?>
    						Chức năng
                        <?php } ?>
                    </td>
                </tr>
            </thead>
            <tbody>
                <?php
                    $stt = 1;
                    foreach ($this->userList as $user){
                ?>
                <tr class="row row-<?php echo $stt;?>">
                    <td class="column text-align-center"><?php echo $user['userId'];?></td>
                    <td class="column">
                        <?php  if($this->acl->checkResource($this->auth,'admin','user','edit')){ ?>
                            <a href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'edit', 'id'=>$user['userId']));?>" title="Sửa thông tin người dùng">
                                <?php echo $user['username']; ?>
                            </a>
                        <?php }else{ ?>
                            <span class="blue"><?php echo $user['username']; ?></span>
                        <?php } ?>
                    </td>
                    <td class="column">
                        <?php
            				foreach($user['roleList'] as $role){
            	                echo '- ',$role['roleName'],'</br>';
            	            }
                        ?>                   
                    </td>
                    <td class="column text-align-center">
                        <?php
                            if($user['status'] == 1){
                                echo '<img src="image/icons/icon_check.png" alt="Đang hoạt động" title="Đang hoạt động" border="0"/>';
                            }else{
                                echo '<img src="image/icons/icon_uncheck.png" alt="Đã Khóa" title="Đã khóa" border="0"/>';
                            }
                        ?>
                    </td>
                    <td class="column text-align-center">
                
                        <?php if($this->acl->checkResource($this->auth,'admin','user','edit')){ ?>
                            <a class="icon icon-edit" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'edit', 'id'=>$user['userId']));?>" title="Sửa thông tin">
                                <img src="image/icons/icon_edit.png" alt="edit user" border="0"/>
                            </a>
                        <?php 
                            }
                            if($this->acl->checkResource($this->auth,'admin','user','delete')){
                                if($this->userCheck['userId'] != $user['userId']){
                        ?>
                    			<a class="icon icon-delete" href="<?php echo $this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'delete', 'id'=>$user['userId']));?>" title="Xóa người dùng">
                                    <img src="image/icons/icon_delete.png" alt="delete user" border="0"/>
                                </a>
                        <?php 
                                }
                            } 
                        ?>
                    </td>
                </tr>
                <?php
                    ++$stt; 
                    } 
                ?>
            </tbody>
        </table>
</div>
